/*
	memory.h

	defines memory sub-system functions

	Author: Aidan Goddard 27/6/14
*/

#ifndef MEMORY_H_INCLUDED
#define MEMORY_H_INCLUDED

#include "types.h"

// initialisation routines
uint64_t memory_init(uint32_t *error);
uint64_t memory_init_step2(uint32_t *error);

// low-level page allocation
typedef uint32_t PAGE_SIZE;
typedef uint32_t PAGE_TYPE;

#define PAGE_SIZE_4K ((PAGE_SIZE)4096)
#define PAGE_SIZE_8K ((PAGE_SIZE)8192)
#define PAGE_SIZE_16K ((PAGE_SIZE)16384)
#define PAGE_SIZE_32K ((PAGE_SIZE)32768)

#define PAGE_TYPE_LOW ((PAGE_TYPE)0xdead)
#define PAGE_TYPE_HIGH ((PAGE_TYPE)0xbeef)

uint64_t memory_get_page(PAGE_SIZE page_size, PAGE_TYPE page_type);
uint64_t memory_free_page(uint64_t page_address, PAGE_SIZE page_size);

uint64_t memory_kernel_get_memory(PAGE_SIZE page_size, uint64_t page_count);
uint64_t memory_kernel_free_memory(uint64_t address);


#endif